using System;
using System.Threading.Tasks;
using Admin2025.Domain.Entities.App;
using Admin2025.Domain.Repositories;

namespace Admin2025.Application
{
    public class RoleService : IRoleService
    {
        private readonly IRepository<AppRolePermission> _rolePermissionRepository;

        public RoleService(IRepository<AppRolePermission> rolePermissionRepository)
        {
            _rolePermissionRepository = rolePermissionRepository;
        }

        public async Task AssignPermissionAsync(Guid roleId, Guid permissionId)
        {
            var rolePerm = new AppRolePermission
            {
                Id = Guid.NewGuid(),
                RoleId = roleId,
                PermissionId = permissionId,
                CreatedAt = DateTime.UtcNow,
                UpdatedAt = DateTime.UtcNow,
                IsActived = true,
                IsDeleted = false,
                CreatedBy = Guid.Empty,
                UpdatedBy = Guid.Empty,
                DisplayOrder = 0,
                Remarks = string.Empty
            };
            await _rolePermissionRepository.InsertAsync(rolePerm);
        }
    }
}
